﻿namespace Socium {
	class DialogSelectionSource : ISelectionSource {
		public object QueryItem(string display_name, object items) {
			var view_model = new SelectionViewModel(display_name, items);
			var dialog = new SelectionDialog();
			view_model.RequestClose += (s, e) => dialog.Close();

			dialog.DataContext = view_model;
			var result = dialog.ShowDialog();
			if (result.HasValue && result.Value) {
				return view_model.SelectedItem;
			}

			return null;
		}
	}
}
